import Vue from 'vue'
import Vuex from 'vuex'
import auInfo from '@/api/my.js'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    userInfo: '',
    isLogin: false
  },
  mutations: {
    setUserInfo (state, value) {
      state.userInfo = value
    },
    setIsLogin (state, value) {
      state.isLogin = value
    }
  },
  actions: {
    resetUserData (store) {
      auInfo().then(res => {
        store.commit('setUserInfo', res.data.data)
        store.commit('setIsLogin', true)
      })
    }
  },
  modules: {}
})

export default store
